import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * service 程序信息
 * @since 2018-6-20
 * @version 0.0.1

 */
import request from 'utils/request';
import { CPAAS_IMP } from 'utils/config';
/**
 * 查询程序列表
 * @param {Object} params - 查询参数
 * @param {String} params.page - 页码
 * @param {String} params.size - 页数
 */

export function query(_x) {
  return _query.apply(this, arguments);
}
/**
 * 新增程序信息
 * @async
 * @function create
 * @param {Object} params - 查询参数
 */

function _query() {
  _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_IMP, "/v1/imported/program/list"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _query.apply(this, arguments);
}

export function create(_x2) {
  return _create.apply(this, arguments);
}
/**
 * 更新程序信息
 * @param {Object} params - 参数
 * @param {String} params.promptKey - 模块代码
 * @param {String} params.promptCode - 代码
 * @param {String} params.lang - 语言名称
 * @param {String} params.description - 描述
 */

function _create() {
  _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_IMP, "/v1/imported/program/info"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _create.apply(this, arguments);
}

export function update(_x3) {
  return _update.apply(this, arguments);
}
/**
 * 删除程序
 * @param {Object} params - 参数
 */

function _update() {
  _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_IMP, "/v1/imported/program/info"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _update.apply(this, arguments);
}

export function remove(_x4) {
  return _remove.apply(this, arguments);
}

function _remove() {
  _remove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(params) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(CPAAS_IMP, "/v1/imported/program/info/").concat(params.id), {
              method: 'DELETE'
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _remove.apply(this, arguments);
}